Promise.myRace = (promises) => {
    return new Promise((rs, rj) => {
        promises.forEach((p) => {
            Promise.resolve(p).then(rs).catch(rj)
        })
    })
}

const promise1 = new Promise((resolve, reject) => {
    setTimeout(resolve, 500, 1)
})

const promise2 = new Promise((resolve, reject) => {
    setTimeout(resolve, 100, 2)
})

Promise.myRace([promise1, promise2]).then((value)=> {
    console.log(value)
})

Promise.myRace([promise1, promise2]).then((value) => {
    console.log(value)
})